<?php
/**
 *教师修改、添加存入数据库中
 */
include "../util/DBUtil.php";
include "../util/PromptAction.php";


$id = $_POST['id'];
$teacher_no = $_POST['teacher_no'];
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$grade_id = $_POST['grade_id'];


$db = new DBUtil();
if ($id == '') {//添加操作
    $sql = "insert into tb_teacher(teacher_no,name,password,grade_id) values (?,?,?,?)";
    $params = array($teacher_no, $name, $pwd, $grade_id);
} else {
    $sql = "update tb_teacher set teacher_no=?,name=?,password=?,grade_id=? where id=? ";
    $params = array($teacher_no, $name, $pwd, $grade_id, $id);
}
//echo $sql;
//print_r($params);

$statue = $db->update($sql, $params);
showStatue($statue);
echo "<script>window.open('../view/teacher.php','info')</script>";
